trigger UpdateOwner on OutletMonthlyOfftake__c (before insert) {
    List<OutletMonthlyOfftake__c> ListOmo = new List<OutletMonthlyOfftake__c>();
    List<ID> ListAcc = new List<ID>();
    Map<Id,Account> ListAccount; //= new map<Id,Id>();
    map<id,id> AccMap = new map<id,id>();    
    if(system.trigger.isinsert){
        for (OutletMonthlyOfftake__c om : Trigger.new)
        {
            if(om.OfftakeValue__c!=NULL && om.OfftakeValue__c>0 || om.OfftakeVolume__c!=NULL && om.OfftakeVolume__c>0)
            {
                if(om.OutletMonthlyOffIsCalc__c == False){
                    ListOmo.add(om);
                    ListAcc.add(om.OutletName__c); 
                    if(!AccMap.containsKey(om.OutletName__c)){
                        AccMap.put(om.OutletName__c,om.OutletName__c); 
                    }
                }
            }
        }
        
        if(AccMap.size() > 0){
            ListAccount =new map<Id,Account>([Select id,name,ownerid From Account Where id in: AccMap.values()]);
        }
        if(ListOmo.size() > 0){
            for(OutletMonthlyOfftake__c omo : ListOmo)
            {
                if(ListAccount.containsKey(omo.OutletName__C))
                {
                    //Account a=ListAccount.get(omo.OutletName__C);
                    omo.ownerid = ListAccount.get(omo.OutletName__C).ownerid;
                }
               /* for(Account acc : ListAccount)
                {
                    if(omo.OutletName__c == acc.id)
                    {
                        omo.ownerid = acc.ownerid;
                    }
                }*/
            }
        }
    }
}